#include "PreCompiled.h"
#include "DrawUnit.h"
#include "view3DInventorViewer.h"
using namespace Gui;
DrawUnit::DrawUnit()
{

}
DrawUnit::~DrawUnit()
{

}


Point::Point(void)
{
}

DrawManager* DrawManager::_instance = 0;
DrawManager::DrawManager()
:LineContext(NULL)
{
   LineContext = GetCKContext(0)->GetPlayerRenderContext();
}
DrawManager::~DrawManager()
{

}

DrawManager* DrawManager::Instance()
{
	if(_instance == 0)
		_instance = new DrawManager();
		
	return _instance;
}
void DrawManager::addPoint(Point* p)
{
  // _pointList.push_back(p);
}
void DrawManager::remvoePoint(Point* p)
{
//    pointItor = _pointList.begin();
//    for(;pointItor != _pointList.end(); pointItor++)
//    {
// 	   if((*pointItor) == p)
// 	   {
// 		   delete *pointItor; 
// 		   _pointList.erase(pointItor);
// 		   break;
// 	   }
//    }
}
void DrawManager::remvoePoint(int index)
{
//    if(index >0 &&index <_pointList.size())
// 	   remvoePoint(_pointList[index]);
	   
}
void DrawManager::Draw()
{
	pointItor = _pointList.begin();
	for(; pointItor != _pointList.end(); pointItor++)
	{
          _renderLine(*pointItor);
	}
}
void DrawManager::_renderLine(LineSegment* ls)
{
	if(LineContext == NULL)
		return;
	CKCurve* c = ls->getLine();
	CKMesh* m = c->GetCurrentMesh();
	if(!m) c->UpdateMesh();
	m = c->GetCurrentMesh();
	m->Render(LineContext,c);

}
